#!/usr/bin/env python

import os
import sys

import beancount.ingest.extract

isSmart = True
try:
    from smart_importer import apply_hooks, PredictPostings
    from smart_importer.detector import DuplicateDetector
    import jieba
    jieba.initialize()
    def tokenizer(s): return list(jieba.cut(s))
except ImportError:
    isSmart = False


beancount.ingest.extract.HEADER = ''
sys.path.append("./")
from importers.cmb_eml import CmbEmlImporter

if isSmart:
    CONFIG = [
        apply_hooks(CmbEmlImporter(), [DuplicateDetector(
        ), PredictPostings(string_tokenizer=tokenizer)])
    ]
else:
    CONFIG = [
        CmbEmlImporter()
    ]
